<script setup>
import useAuthStore from '@/store/auth'
import { LOGIN_URL } from '@/config'
import api from '@/api'
import { useRouter } from 'vue-router'

const $authStore = useAuthStore()
const $router = useRouter()

const logout = async () => {
  showConfirmDialog({
    title: '退出登录',
    message: '确定要退出登录吗？',
  })
    .then(async () => {
      //   try {
      await api.post('/auth/logout')
      $router.replace({ path: LOGIN_URL + '/' + $authStore.company.number })
      $authStore.clear()
      //   } catch (error) {}
    })
    .catch(() => {})
}
</script>

<template>
  <div class="page-profile">
    <!-- <van-cell-group style="margin-bottom: 20px">
      <van-cell>
        <template #title>
          <div class="username">{{ $authStore.name }}({{ $authStore.username }})</div>
          <div class="company">{{ $authStore.company.name }}</div>
        </template>
      </van-cell>
    </van-cell-group> -->

    <van-cell-group style="margin-bottom: 20px">
      <van-cell title="剩余剪辑次数" :value="$authStore.clip_num" />
    </van-cell-group>

    <van-cell-group>
      <van-cell title="我的收藏" is-link @click="$router.push('/ip/materials/favorites')" />
      <van-cell title="意见反馈" is-link @click="$router.push('/feedback')" />
    </van-cell-group>
  </div>
</template>

<style lang="scss" scoped>
.page-profile {
  width: 100vw;
  height: 100vh;
  background: #f7f8fa;

  .username {
    font-size: 16px;
    font-weight: bold;
  }
  .company {
    color: #999999;
    font-size: 13px;
    margin-top: 5px;
  }
}
</style>
